home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / basic / qbfaqr01.zip / NETID.BAS < prev    next >
BASIC Source File  |  1992-08-10  |  2KB  |  53 lines

  1. 'Date: 05-22-92 (12:20)
  2. 'From: TONY ELLIOTT
  3. '-------------------------------------------------------------------------
  4. 'MK>Does anybody have a routine to check either the network node ID or the
  5. 'MK>card id on a NetBios based network, such as LanTastic?
  6.  
  7. 'Here's a little routine you can use to return the machine name and ID
  8. 'on NetBios compatible networks. It'll return a null string if a
  9. 'compatible network is not running. Hope it helps.
  10.  
  11. '-------------------
  12. DEFINT A-Z
  13.  
  14. DECLARE FUNCTION MachineName$ (MachineNumber%)
  15. REM $INCLUDE: 'QBX.BI'                           'Use QB.BI for QB4.x
  16.  
  17. ThisMachine$ = MachineName$(MachineNumber%)
  18. IF LEN(ThisMachine$) THEN
  19.     PRINT "Machine Name: "; ThisMachine$
  20.     PRINT "   Machine #:"; MachineNumber%
  21. ELSE
  22.     PRINT "NetBIOS compatible network not installed."
  23. END IF
  24.  
  25. FUNCTION MachineName$ (MachineNumber%)
  26.  
  27.     'If a NetBIOS compatible network is installed, this function returns
  28.     'the machine name as a result of the function and the machine's NetBIOS
  29.     'ID number in the MachineNumber% parameter.
  30.  
  31.     'If a network is not detected, the function returns a null string.
  32.  
  33.     DIM Reg AS RegTypeX                 'In QB.BI (or QBX.BI if using PDS)
  34.     DIM Temp AS STRING * 16             'Buffer to hold machine name
  35.     MachineNumber% = 0                  'Make sure it is zero
  36.     Reg.ax = 0                          'Use function 0 of interrupt 2ah
  37.     CALL InterruptX(&H2A, Reg, Reg)
  38.     IF Reg.ax AND &HFF00 THEN           'If AH <> 0 then network was found
  39.         Reg.ax = &H5E00
  40.         Reg.ds = VARSEG(Temp)
  41.         Reg.dx = VARPTR(Temp)
  42.         CALL InterruptX(&H21, Reg, Reg)
  43.         IF Reg.flags AND 1 THEN         'Did an error occur?
  44.             EXIT FUNCTION
  45.         END IF
  46.         MachineNumber% = Reg.cx AND &HFF    'Machine # in CL
  47.         MachineName$ = RTRIM$(Temp)
  48.     END IF
  49.  
  50. END FUNCTION
  51.  
  52. '-------------
  53.